﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>呷饭网</title>
    <link rel="stylesheet" type="text/css" href="styles/mobile.css" />
    <link href="styles/jquery.ui.all.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.bgiframe-2.1.1.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.core.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.mouse.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.button.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.draggable.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.position.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.dialog.js"></script>
    <link href="styles/flexy-menu.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/flexy-menu.js"></script>
    <script type="text/javascript" src="scripts/common.js"></script>

    <script type="text/javascript">
        var PageFlag;
        $(function () {
            $(".flexy-menu").flexymenu({ speed: 100 });
            getUserInfo();
            getListData("");
            PageFlag = getParameter("PageFlag");
            $('.goback').click(function () {
                if (PageFlag == "1") {
                    window.location.href = "./manager.html";
                }
                else {
                    window.location.href = "./login.html";
                }
            });
        }); 
        function getListData(flag) {
            getDineTableList(flag);
        }

        //获取酒店订单信息
        function getDineTableList(flag) {
            $("#tbllist").html("");

            if (flag == "Rooms") {
                $("#all").removeClass("active");
                $("#hall").removeClass("active");
                $("#add").removeClass("active");
                $("#rooms").addClass("active");
            }
            else if (flag == "Hall") {
                $("#all").removeClass("active");
                $("#rooms").removeClass("active");
                $("#add").removeClass("active");
                $("#hall").addClass("active");
            }
            else if (flag == "Add") {
                $("#all").removeClass("active");
                $("#rooms").removeClass("active");
                $("#hall").removeClass("active");
                $("#add").addClass("active");
            }
            else{
                $("#rooms").removeClass("active");
                $("#hall").removeClass("active");
                $("#add").removeClass("active");
                $("#all").addClass("active");
            }

            if (flag == "Add") {
                var datas = "&flag=" + flag;
                var url = "CommonPage.aspx?opration=getHandleType" + datas;
                $.ajax({
                    url: url,
                    type: "post",
                    dataType: 'json',
                    success: function (data) {
                        if (data.Success) {
                            $(".tips")[0].style.display = "none";
                            for (var i = 0, str = ''; i < data.List.length; i++) {
                                if (data.List[i].OrderId == "") {
                                    str += "<tr style='height:10px;'><td class='l'>" + data.List[i].Name + "<br/>(" + data.List[i].Category + ")</td><td class='c' style='vertical-align:middle'>可坐人数：" + data.List[i].Numbers + "人</td><td class='r' style='vertical-align:middle'><a href='#' name='" + data.List[i].Name + "' dir='" + data.List[i].Category + "' onclick='openDineTable(this," + data.List[i].HotelId + "," + data.List[i].SeatId + ",\"clean.html\",2);'>开台</a></td></tr>";
                                }
                            }
                            $("#tbllist").html(str);
                        }
                        else {
                            if (data.Url != "") {
                                updateTip(data.Msg, true, "URL", data.Url);
                            }
                            else {
                                $(".tips")[0].style.display = "";
                                $("#msgtip").text(data.Msg);
                            }
                        }
                    }
                });
            }
            else {
                var datas = "&flag=" + flag;
                var url = "CommonPage.aspx?opration=getDineTableList" + datas;
                $.ajax({
                    url: url,
                    type: "post",
                    dataType: 'json',
                    success: function (data) {
                        if (data.Success) {
                            $(".tips")[0].style.display = "none";
                         /*   var OrderState = 0;
                            var RoomNumber = 0;*/
                            for (var i = 0, str = ''; i < data.List.length; i++) {
                                if (data.List[i].TableState == 1 && data.List[i].OrderState == 4) {
                                    str += "<tr><td class='l'>" + data.List[i].Name + "</td><td class='l'>" + data.List[i].Category + "</td><td class='c'>" + data.List[i].RoomNumber + "</td><td class='c'>" + data.List[i].CreateTime + "</td><td class='r'><a href='tbldetails.html?PageFlag=2&HotelId=" + data.HotelId + "&OrderId=" + data.List[i].OrderId + "&Name=" + encodeURIComponent(data.List[i].Name) + "&H_Name=" + encodeURIComponent($("#H_Name")[0].innerHTML) + "'>催菜</a></td></tr>";
                                }
                                else if (data.List[i].TableState == 0 && data.List[i].OrderState == 4) {
                                    str += "";
                                }
                                else if (data.List[i].TableState == 0 && data.List[i].OrderState == 5 || data.List[i].OrderState == 7) { 
                                   /* if (data.List[i].OrderState == OrderState && data.List[i].RoomNumber == RoomNumber) {
                                        continue;
                                    }*/
                                    str += "<tr><td class='l'>" + data.List[i].Name + "</td><td class='l'>" + data.List[i].Category + "</td><td class='c'>" + data.List[i].RoomNumber + "</td><td class='c'>" + data.List[i].CreateTime + "</td><td class='r'><a href='#' onclick='cleanDineTable(" + data.List[i].OrderId + "," + data.List[i].DineTableId + ");'>清台</a></td></tr>";
                                  /*  OrderState = data.List[i].OrderState;
                                    RoomNumber = data.List[i].RoomNumber;*/
                                }
                                else {
                                    $(".tips")[0].style.display = "";
                                    $("#msgtip").text("没有查询到相关数据");
                                }
                            }
                            if (str == "") {
                                $(".tips")[0].style.display = "";
                                $("#msgtip").text("没有查询到相关数据");
                            }
                            else {
                                $("#tbllist").html(str);
                            }
                        }
                        else {
                            if (data.Url != "") {
                                updateTip(data.Msg, true, "URL", data.Url);
                            }
                            else {
                                $(".tips")[0].style.display = "";
                                $("#msgtip").text(data.Msg);
                            }
                        }
                    }
                });
            }
        }

        //清台
        function cleanDineTable(OrderId, DineTableId) {
            var datas = "&OrderId=" + OrderId + "&DineTableId=" + DineTableId;
            var url = "CommonPage.aspx?opration=cleanDineTable" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    $(this).dialog("close");
                    if (data.Success) {
                        //updateTip(data.Msg, true, "Method", "");
                        getListData("");
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            updateTip(data.Msg, false, "", "");
                        }
                    }
                }
            });
        }
    </script>
</head>

<body>
    <div class="wrapall">
        <table class="topbar">
            <tr>
                <td class="l"><a class="goback">返回</a></td>
                <td class="c" id="H_Name"></td>
                <td class="r" align="right">
                    <ul class="flexy-menu">
                        <li id="lilist">
                        </li>
                    </ul>
                </td>
            </tr>
        </table>
        <table class="tab1">
            <tr>
                <td class="active" id="all"><a href="#" onclick="getDineTableList('');">全部</a></td>
                <td id="rooms"><a href="#" onclick="getDineTableList('Rooms');">包厢</a></td>
                <td id="hall"><a href="#" onclick="getDineTableList('Hall');">大厅</a></td>
                <td id="add"><a href="#" onclick="getDineTableList('Add');">开台</a></td>
            </tr>
        </table> 
        <table class="tbllist" id="tbllist">
        </table>
        <span class="tips" style="display: none;"><i></i><b id="msgtip"></b>

        </span>
        <br />
    </div>
    <div id="dialog" title="提示信息" style="text-align:center; vertical-align: middle;">
        <p class="dialogTip"></p>
    </div>
</body>
</html>
